package org.example.compent;

import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.annotation.LiteflowMethod;
import com.yomahub.liteflow.core.NodeComponent;
import com.yomahub.liteflow.enums.LiteFlowMethodEnum;
import com.yomahub.liteflow.enums.NodeTypeEnum;
import com.yomahub.liteflow.slot.DefaultContext;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@LiteflowComponent
public class CmpConfig {

    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "a1", nodeType = NodeTypeEnum.COMMON)
    public void processA(NodeComponent bindCmp) {
        log.info("------组件a1-------");
    }

    @LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "a1", nodeType = NodeTypeEnum.COMMON)
    public boolean isAccessA(NodeComponent bindCmp){
        log.info("-------组件a1是否执行---------");
        return true;
    }

    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN, nodeId = "b1", nodeType = NodeTypeEnum.BOOLEAN)
    public boolean processB(NodeComponent bindCmp) {
        DefaultContext contextBean = bindCmp.getContextBean(DefaultContext.class);
        boolean retult = contextBean.getData("flag");
        log.info("------组件b1条件判读结点:{}-------", retult);
        return retult;
    }

    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN, nodeId = "b1", nodeType = NodeTypeEnum.BOOLEAN)
    public boolean isAccessB(NodeComponent bindCmp){
        log.info("-------组件b1是否执行---------");
        return true;
    }

    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN, nodeId = "condition1", nodeType = NodeTypeEnum.BOOLEAN)
    public boolean processCondition1(NodeComponent bindCmp) {
        DefaultContext contextBean = bindCmp.getContextBean(DefaultContext.class);
        boolean retult = contextBean.getData("condition1");
        log.info("------组件condition条件判读结点:{}-------", retult);
        return retult;
    }

    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN, nodeId = "condition1", nodeType = NodeTypeEnum.BOOLEAN)
    public boolean isAccessProcessCondition(NodeComponent bindCmp){
        log.info("-------组件condition是否执行---------");
        return true;
    }

    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN, nodeId = "condition2", nodeType = NodeTypeEnum.BOOLEAN)
    public boolean processCondition2(NodeComponent bindCmp) {
        DefaultContext contextBean = bindCmp.getContextBean(DefaultContext.class);
        boolean retult = contextBean.getData("condition2");
        log.info("------组件condition2条件判读结点:{}-------", retult);
        return retult;
    }

    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_BOOLEAN, nodeId = "condition2", nodeType = NodeTypeEnum.BOOLEAN)
    public boolean isAccessProcessCondition2(NodeComponent bindCmp){
        log.info("-------组件condition2是否执行---------");
        return true;
    }

    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS_FOR, nodeId = "c1", nodeType = NodeTypeEnum.FOR)
    public int processC(NodeComponent bindCmp) {
        DefaultContext contextBean = bindCmp.getContextBean(DefaultContext.class);
        int count = contextBean.getData("count");
        log.info("------组件c1-------");
        return count;
    }

    @LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "c1", nodeType = NodeTypeEnum.FOR)
    public boolean isAccessC(NodeComponent bindCmp){
        log.info("-------组件c1是否执行---------");
        return true;
    }

    @LiteflowMethod(value = LiteFlowMethodEnum.PROCESS, nodeId = "d1", nodeType = NodeTypeEnum.COMMON)
    public void processD(NodeComponent bindCmp) {
        log.info("------组件d1-------");
    }

    @LiteflowMethod(value = LiteFlowMethodEnum.IS_ACCESS, nodeId = "d1", nodeType = NodeTypeEnum.COMMON)
    public boolean isAccessD(NodeComponent bindCmp){
        log.info("-------组件d1是否执行---------");
        return true;
    }




}
